package com.zhentao.controller;

import com.zhentao.model.common.dtos.ResponseResult;
import com.zhentao.model.pojo.user.product.ChargeUserProduct;
import com.zhentao.service.ChargeUserProductService;
import com.zhentao.service.ChargeUserUserProductService;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import javax.annotation.Resource;

@RestController
@RequestMapping("/auth/user")
public class ProductController {

    @Resource
    private ChargeUserProductService productService;



    @GetMapping("/product/getProducts")
    public ResponseResult getProducts(){
        return productService.getProducts();
    }

    @PostMapping("/product/addProduct")
    public ResponseResult addProduct(@RequestBody ChargeUserProduct product){
        return productService.addProduct(product);
    }

    @PostMapping("/product/updateProduct")
    public ResponseResult updateProduct(@RequestBody ChargeUserProduct product){
        return productService.updateProduct(product);
    }

    @PostMapping("/product/deleteProduct")
    public ResponseResult deleteProduct(@RequestParam("id") Integer id){
        return productService.deleteProduct(id);
    }

    @PostMapping("/product/exchangeProdut")
    public ResponseResult exchangeProdut(@RequestParam("id") Integer id){
        return productService.exchangeProdut(id);
    }

    @GetMapping("/product/getUserProducts")
    public ResponseResult getUserProducts(){
        return productService.getUserProducts();
    }

    @PostMapping("/product/uplodaImg")
    public ResponseResult uplodaImg(@RequestBody MultipartFile file){
        return productService.uploadImg(file);
    }
}
